#include <bits/stdc++.h>
#define up(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;

const int N = 21;
typedef long long ll;
typedef __int128_t Long;
const ll mod = 998244353;

ll n;

struct Mat {
    ll a[N][N];
    void set(int v) {
        memset(a, 0, sizeof a);
        if (v)
            up(i, 0, n) a[i][i] = 1;
    }
    Mat operator*(Mat _) {
        Mat r;
        r.set(0);
        up(i, 0, n) up(k, 0, n) up(j, 0, n)(r.a[i][j] += a[i][k] * _.a[k][j] % mod) %= mod;
        return r;
    }
    Mat operator+(Mat _) {
        Mat r;
        r.set(0);
        up(i, 0, n) up(j, 0, n) r.a[i][j] = (a[i][j] + _.a[i][j]) % mod;
        return r;
    }
} A, B, zero, one;

struct Node {
    Mat A, B, ans;
    void set() { A.set(1), B.set(1), ans.set(0); }
    Node operator*(Node _) { return { A * _.A, B * _.B, ans + A * _.ans * B }; }
};

istream& operator>>(istream& in, Mat& b) {
    up(i, 0, n) up(j, 0, n) in >> b.a[i][j];
    return in;
}

Node pow(Node a, ll b) {
    Node r;
    r.set();
    for (; b > 0; b >>= 1, a = a * a)
        if (b & 1)
            r = r * a;
    return r;
}

Node f(ll a, ll b, ll c, ll n, Node U, Node R) {
    assert(b < c);
    ll m = ((Long)a * n + b) / c;
    if (!m)
        return pow(R, n);
    if (a >= c)
        return f(a % c, b, c, n, U, pow(U, a / c) * R);
    return pow(R, (c - b - 1) / a) * U * f(c, (c - b - 1) % a, a, m - 1, R, U) *
           pow(R, n - ((Long)c * m - b - 1) / a);
}

signed main() {
    ll p, q, r, l;
    cin >> p >> q >> r >> l >> n >> A >> B;
    one.set(1);
    Node U = { one, B, zero };
    Node R = { A, one, A };
    Mat ret = (pow(U, r / q) * f(p, r %= q, q, l, U, R)).ans;
    up(i, 0, n) up(j, 0, n) cout << ret.a[i][j] << (" \n"[j + 1 == n]);
    return 0;
}

struct Init {
    Init() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
    ~Init() { cout.flush(); }
} wtl;